package sqlTestes.tPrimaryKey;

import java.util.ArrayList;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import sql.ddl.PrimaryKey;
import sql.ddl.coluna.Coluna;

public class TestePrimaryKey implements Especificacao {
	PrimaryKey pk = null;

	PrimaryKey pkB = null;

	@Before
	public void up() {
		ArrayList<Coluna> colunas = new ArrayList<Coluna>();
		colunas.add(new Coluna("INTEGER", "a", false));
		pk = new PrimaryKey(colunas);

		ArrayList<Coluna> colunasb = new ArrayList<Coluna>();
		colunasb.add(new Coluna("INTEGER", "a", false));
		colunasb.add(new Coluna("INTEGER", "b", false));
		pkB = new PrimaryKey(colunasb);
	}

	@Test
	public void codigoSQLColunaINTEGERa() {
		Assert.assertEquals("PRIMARY KEY(a)", pk.codigoSQL());
	}

	@Test
	public void codigoSQLColunaINTEGERab() {
		Assert.assertEquals("PRIMARY KEY(a,b)", pkB.codigoSQL());
	}

	@Test
	public void codigoSQLColunaINTEGERaCONSTRAINTagua() {
		pk.setConstraint("agua");
		Assert.assertEquals("CONSTRAINT agua PRIMARY KEY(a)", pk.codigoSQL());
	}

}
